import {
  Controller,
  Get,
  Post,
  Body,
  Query,
  Request,
  Redirect,
} from '@nestjs/common';
import { AuthService } from 'src/service/auth.service';
import { AuthDto } from 'src/dto/auth.dto';
import { AuthStoreRegisterDto } from 'src/dto/authStoreRegister.dto';

@Controller('api/auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  @Post('authLogin')
  authLogin(@Request() request) {
    return this.authService.authLogin(request);
  }

  @Post('signup')
  signup(@Body() authDto: AuthDto) {
    return this.authService.signup(authDto);
  }

  @Post('register')
  register(@Body() authDto: AuthDto) {
    return this.authService.register(authDto);
  }

  @Post('registerStore')
  registerStore(@Body() authStoreRegisterDto: AuthStoreRegisterDto) {
    return this.authService.registerStore(authStoreRegisterDto);
  }

  @Post('lostPassword')
  lostPassword(@Query('phone') phone,) {
    return this.authService.lostPassword(phone,);
  }

  @Post('changePassword')
  changePassword(@Body() body: any) {
    let { uid, authCode, password } = body;
    return this.authService.changePassword(uid, authCode, password);
  }
}
